public class Windows implements Runnable {
    private int ticket=100;
    @Override
    public void run() {
        while(true){
            synchronized(this){
                if(ticket>0)
                {
                    System.out.println(Thread.currentThread().getName()+"出票，票号为:"+ticket);
                    try {
                        Thread.currentThread().sleep(100);
                    } catch (Exception e) {
                        //TODO: handle exception
                    }
                    ticket--;
                }
                else
                    break;
            }
        }
    }
}
